import axiosInstance from '../http/axios';

export const uploadVideo = async (data: {
  file: Blob;
  fileHash: string;
  chunkIndex: number;
}) => {
  const formData = new FormData();
  Object.entries(data).forEach(([key, value]) => {
    if (value instanceof Blob) {
      formData.append(key, value);
    } else {
      // 将 number、boolean 等转为 string
      formData.append(key, String(value));
    }
  });
  return axiosInstance.post('/upload', formData);
};

export const mergeVideo = async (data: {
  fileHash: string;
  fileName: string;
}) => {
  return axiosInstance.get('/upload/merge', { params: data });
};
